<template>
  <div class="rankinggame" :class="{ rankinggames: schang }">
    <div class="rankinggame-item" v-for="(item, index) in list" :key="index">
      <div class="rgame-one">
        <img v-if="index == 0" src="../../../assets/img/one.svg" alt="" />
        <img v-if="index == 1" src="../../../assets/img/tow.svg" alt="" />
        <img v-if="index == 2" src="../../../assets/img/disan.svg" alt="" />
        <span
          class="rgame-span"
          v-if="index != 0 && index != 1 && index != 2"
          >{{ index + 1 }}</span
        >
      </div>

      <div class="rgame-tow">
        <img
          class="rgame-simg"
          :src="item.giLogo"
          alt=""
          @click="goGame(item.giId)"
        />
        <div class="changBox">
          <xing :giScore="item.giScore"></xing>
          <span>{{ item.giScore }}</span>
        </div>
      </div>

      <div class="rgame-three">
        <div @click="goGame(item.giId)" class="rgame-threeOne">
          {{ item.giName }}
        </div>
        <div class="rgame-threeTow">{{ item.gjOperator }}</div>
        <div class="rgame-threeThre" v-html="item.giTitle"></div>
        <div class="rgame-threefour">
          <span>{{ item.gtName }}</span>
        </div>
      </div>

      <div class="rgame-four">
        <img :src="item.giBackdrop" alt="" @click="goGame(item.giId)" />
      </div>
    </div>

    <div v-if="nones" class="rankingBottom">没有更多数据了</div>
  </div>
</template>

<script>
import Xing from "../../../components/ximg/Xing.vue";
export default {
  components: { Xing },
  name: "RankingGame",
  props: {
    list: {
      type: Array,
    },
    nones: {
      type: Boolean,
    },
  },
  data() {
    return {
      schang: false,
    };
  },

  mounted() {
    // 监听滚动条是否滚动到某地
    console.log(this.list);
    window.addEventListener("scroll", this.scrollNav);
  },
  methods: {
    scrollNav() {
      let top = document.documentElement.scrollTop;
      if (top > 150) {
        // 当页面滚动到高度250px处，动态绑定class 来设置头部固定定位
        this.schang = true;
      } else {
        this.schang = false;
      }
    },

    goGame(id) {
      this.$router.push({ name: "详情", params: { id: id } });
    },
  },
};
</script>

<style>
.rankinggame {
  width: 90%;
  margin-left: 0.3rem;
  padding-bottom: 0.2rem;
  position: relative;
}

.rankinggame-item {
  display: flex;
  border-bottom: 1px solid rgb(207, 206, 206);
  padding-bottom: 0.2rem;
  margin-top: 0.1rem;
  padding-top: 0.1rem;
}

.rankinggames {
  margin-left: 1rem;
}

.changBox {
  display: flex;
  align-content: center;
}

.rgame-one {
  width: 0.35rem;
  margin-right: 0.2rem;
}

.rgame-span {
  display: block;
  width: 0.28rem;
  height: 0.28rem;
  background-color: rgb(125, 214, 250);
  color: #fff;
  font-size: 0.14rem;
  border-radius: 50%;
  text-align: center;
  line-height: 0.28rem;
}

.rgame-one img {
  width: 100%;
}

.rgame-tow {
  width: 1rem;
  text-align: center;
  margin-right: 0.2rem;
}

.rgame-simg {
  cursor: pointer;
  width: 100%;
  border-radius: 20%;
  margin-bottom: 0.2rem;
  display: flex;
  align-content: center;
}

.changBox span {
  font-size: 0.11rem;
  margin-left: 0.1rem;
}

.rgame-three {
  width: 2.5rem;
  margin-right: 0.2rem;
}

.rgame-threeOne {
  font-size: 0.15rem;
  margin-bottom: 0.06rem;
  cursor: pointer;
}

.rgame-threeOne:hover {
  color: rgb(125, 214, 250);
}

.rgame-threeTow {
  font-size: 0.08rem;
  margin-bottom: 0.06rem;
  color: rgb(161, 163, 165);
}

.rgame-threeThre {
  font-size: 0.1rem;
  height: 0.42rem;
  line-height: 0.15rem;
  margin-bottom: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3; /*想省略几行就写几*/
  -webkit-box-orient: vertical;
}

.rgame-threefour span {
  font-size: 0.07rem;
  margin-bottom: 0.3rem;
  border: 1px solid rgb(216, 213, 210);
  padding: 0.03rem 0.03rem 0.03rem 0.03rem;
  border-radius: 0.03rem;
  color: rgb(161, 163, 165);
  cursor: pointer;
}

.rgame-threefour span:hover {
  color: rgb(125, 214, 250);
  border-color: rgb(125, 214, 250);
}

.rgame-four {
  width: 2.7rem;
  overflow: hidden;
  border-radius: 20px;
  cursor: pointer;
}

.rgame-four img {
  width: 100%;
  height: 1.4rem;
  border-radius: 20px;
  transition: all 0.5s;
}

.rgame-four img:hover {
  transform: scale(1.2);
}

.rankingBottom {
  width: 80%;
  font-size: 0.13rem;
  text-align: center;
  margin-top: 0.3rem;
  margin-bottom: 0.4rem;
}
</style>